<?php


namespace app\api\controller\v21;


use app\api\controller\v2\Auth;
use app\common\cachemodel\UserCoupon;
use think\response\Json;

class Coupon extends Auth
{
    /**
     * 优惠券删除
     * @return Json
     * @throws \Exception
     */
    public function del()
    {
        $cid = input('cid/d', 0);

        if (!$cid)
        {
            return show(config('code.error'), '服务异常，请稍后再试～');
        }

        $userCoupon = new UserCoupon();

        $res = $userCoupon->couponDel($this->user['id'], $cid);

        if ($res)
        {
            return show(config('code.success'), '删除成功');
        } else
        {
            return show(config('code.error'), $userCoupon->errorMsg);
        }
    }
}
